package samples;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.JavaSoundAudioDevice;
import javazoom.jl.player.JavaSoundAudioDeviceFactory;
import javazoom.jl.player.Player;
import javazoom.jl.player.jlp;
import javazoom.jl.player.advanced.AdvancedPlayer;
import javazoom.jl.player.advanced.PlaybackListener;

public class Mp3PlayerTest implements Runnable {
	Player player;
				
	public Mp3PlayerTest(Player player) {
		super();
		this.player = player;
	}

	@Override
	public void run() {		
		try {
			player.play();
		} catch (JavaLayerException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	/**
	 * @param args
	 * @throws Exception 
	 * @throws FileNotFoundException 
	 */
	public static void main(String[] args) throws FileNotFoundException, Exception {
		Player player = new Player(new FileInputStream("G:\\Albums\\Air\\Air - Talkie Walkie\\Air - 02 - Cherry Blossom Girl.mp3"));
		
		Thread playerThread = new Thread(new Mp3PlayerTest(player));
		playerThread.start();				
		
		for (int i = 15; i > 0; i--) {
			System.out.println("Killing in " + i + " ...");
			//System.out.println(player.getPosition());
			Thread.sleep(1000);					
		}
		
		player.close();

	}	
}
